package test;

import java.io.Serializable;
import java.util.*;

import org.lsda.util.Util;

public class Job implements Serializable {

	private int jobId = -1;
	
	private String jobName="";
	
	private String jobDesc="";

	private Date reqTime = null;

	private Date rspTime = null;

	private ArrayList<Action> actions = new ArrayList<Action>();

	public Job() {
		jobId = Util.autoIncrementID("jobid");
	}
	
	public Job(String jobName,String jobDesc)
	{
		jobId = Util.autoIncrementID("jobid");
		this.jobName = jobName;
		this.jobDesc = jobDesc;
	}
	public boolean notEmptyJob(){
		if(getSize()==0)
			return true;
		else
			return false;
	}
	public int getSize(){
		return actions.size();
	}
	
	public void setAction(Action act)
	{
		actions.set(act.getSubJobId(), act);
	}
	
	public Action getAction(int index){
		assert(index>=0&& index<getSize());
		return actions.get(index);
	}
	
	public void addAction(Action act)
	{
		act.setJobId(jobId);
		act.setSubJobId(getSize());
		actions.add(act);
	}
	
	public void insertAction(int index,Action act){
		assert(index>=0&& index<getSize());
		act.setJobId(jobId);
		actions.add(index, act);
	}
	

	public int getJobId() {
		return jobId;
	}

	public void setJobId(int jobId) {
		this.jobId = jobId;
	}

	
	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	public String getJobDesc() {
		return jobDesc;
	}

	public void setJobDesc(String jobDesc) {
		this.jobDesc = jobDesc;
	}

	public Date getReqTime() {
		return reqTime;
	}

	public void setReqTime(Date reqTime) {
		this.reqTime = reqTime;
	}

	public Date getRspTime() {
		return rspTime;
	}

	public void setRspTime(Date rspTime) {
		this.rspTime = rspTime;
	}

	public ArrayList<Action> getActions() {
		return actions;
	}

	public void setActions(ArrayList<Action> actions) {
		this.actions = actions;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(new Date());
	}

}
